var t, e = require("../../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page((e(t = {
    data: {
        navInd: 0,
        navArr: [],
        shopShow: !1,
        classInfoOne: [],
        userInfo: [],
        ClassTypeInfo: [],
        kid: null,
        shopListMember: [],
        shopListMemberLoadMore: !1,
        shopListPgae: 1,
        member_type: 2,
        ThrMemberArr: [],
        debtUid: "",
        jurisdiction: !1
    },
    onLoad: function(t) {
        if (wx.setNavigationBarTitle({
            title: "债务人店铺"
        }), t.kid && this.setData({
            kid: t.kid
        }), t.member_type && this.setData({
            member_type: t.member_type
        }), t.debtUid && this.setData({
            debtUid: t.debtUid
        }), t.scene) {
            var e = decodeURIComponent(t.scene);
            if (e) {
                var o = [];
                o = e.split(",");
                for (var s = 0; s < o.length; s++) {
                    var i;
                    "mid" == (i = o[s].split("="))[0] && a._setMid(i[1]), "debtUid" == i[0] && this.setData({
                        debtUid: i[1]
                    });
                }
            }
        }
        this.getUser(), this.getClassType(), this.setData({
            plugin_setting: wx.getStorageSync("yz_basic_info").plugin_setting.debt_shop || {}
        });
    },
    tapNav: function(t) {
        var e = t.currentTarget.dataset.key;
        this.setData({
            navInd: e
        }), 2 == e && this.getThrMember();
    },
    goSwitchShop: function(t) {
        console.log(t);
        var e = t.currentTarget.dataset.item.debtor_id;
        wx.navigateTo({
            url: "/packageF/debt/debtor/debtorShop/debtorShop?kid=" + e + "&member_type=1"
        });
    },
    goSwitchShopHome: function() {
        wx.reLaunch({
            url: "/packageG/index/index"
        });
    },
    getThrMember: function() {
        var t = this, e = {
            member_type: 1
        };
        this.data.userInfo.debtor_id && (e.debtor_id = this.data.userInfo.debtor_id);
        var o = a.getNetAddresss("plugin.debt-shop.frontend.debt-member.getDebtData");
        a._getNetWork({
            url: o,
            data: e,
            success: function(e) {
                var a = e.data;
                1 == a.result ? t.setData({
                    ThrMemberArr: a.data
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    toClassSearch: function(t) {
        var e = t.currentTarget.dataset.item.id;
        if (0 == e && "全部分类" == t.currentTarget.dataset.item.name) return console.log("全部分类"), 
        void this.setData({
            navInd: 1
        });
        wx.navigateTo({
            url: "/packageA/member/supplier/SupplierSearch/SupplierSearch?debtCId=" + e + "&debtId=" + this.data.userInfo.debtor_id
        });
    },
    toSearch: function(t) {
        wx.navigateTo({
            url: "/packageA/member/supplier/SupplierSearch/SupplierSearch?debtSearch=true&debtId=" + this.data.userInfo.debtor_id
        });
    },
    shopCloseTap: function() {
        this.setData({
            shopShow: !1
        });
    },
    shopShowTap: function() {
        this.setData({
            shopShow: !0
        }), this.SwitchoverListInit(), this.getSwitchoverList();
    },
    sortOut: function(t) {
        console.log(t, "sortOut");
    },
    toVIP: function() {
        wx.navigateTo({
            url: "/packageF/debt/vipAdd/vipAdd?debtId=" + this.data.userInfo.debtor_id
        });
    },
    toMyorder: function() {
        wx.navigateTo({
            url: "/packageA/member/myOrder_v2/myOrder_v2?member_type=1&debtId=" + this.data.userInfo.debtor_id
        });
    },
    toDetail: function() {
        wx.navigateTo({
            url: "/packageF/debt/purchaseDetails/purchaseDetails?coupon=true&debtId=" + this.data.userInfo.debtor_id
        });
    },
    onReady: function() {},
    onShow: function() {
        2 == this.data.navInd && this.getThrMember();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (0 == this.data.navInd) if (this.data.current_page >= this.data.good_total_page) console.log("没有更多"); else {
            console.log("加载下一页");
            var t = this.selectComponent("#sort");
            t.setData({
                good_page: t.data.good_page + 1
            }), t.nexTgetGoodsData();
        }
    },
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), e = "";
        t && (e = t);
        return {
            path: this.data.debtUid ? "/packageF/debt/debtor/debtorShop/debtorShop?debtUid=" + this.data.debtUid + "&mid=" + e : this.data.kid ? "/packageF/debt/debtor/debtorShop/debtorShop?kid=" + this.data.kid + "&mid=" + e : "/packageF/debt/debtor/debtorShop/debtorShop?mid=" + e
        };
    }
}, "sortOut", function(t) {
    this.setData({
        current_page: t.detail.current_page,
        good_total_page: t.detail.good_total_page
    });
}), e(t, "SwitchoverListInit", function() {
    this.setData({
        shopListPgae: 1,
        shopListMemberLoadMore: !1,
        shopListMember: []
    });
}), e(t, "getSwitchoverList", function() {
    var t = this, e = a.getNetAddresss("plugin.debt-shop.frontend.owner.debtorList");
    a._getNetWork({
        url: e,
        data: {
            is_use: 1,
            page: this.data.shopListPgae
        },
        success: function(e) {
            var a = e.data;
            1 == a.result ? (console.log(a, "获取店铺切换列表"), a.data.current_page < a.data.last_page ? t.setData({
                shopListMemberLoadMore: !0
            }) : a.data.current_page >= a.data.last_page && t.setData({
                shopListMemberLoadMore: !1
            }), t.data.shopListMemberLoadMore ? t.setData({
                shopListMember: t.data.shopListMember.concat(a.data.data)
            }) : t.setData({
                shopListMember: a.data.data
            })) : wx.showToast({
                icon: "none",
                title: a.msg,
                duration: 1500
            });
        },
        fail: function(t) {
            console.log(t);
        }
    });
}), e(t, "getUser", function() {
    var t = this, e = {};
    console.log(this.data.debtor_uid, "aaaaaaaaaa"), e = this.data.debtUid ? {
        debtor_uid: this.data.debtUid
    } : {
        debtor_id: this.data.kid ? this.data.kid : ""
    };
    var o = a.getNetAddresss("plugin.debt-shop.frontend.debt-member.getDebtor");
    a._getNetWork({
        url: o,
        data: e,
        success: function(e) {
            var a = e.data;
            1 == a.result ? t.setData({
                userInfo: a.data,
                member_type: a.data.member_type,
                jurisdiction: !0
            }) : (wx.showToast({
                icon: "none",
                title: a.msg,
                duration: 1500
            }), t.setData({
                jurisdiction: !1
            }));
        },
        fail: function(t) {
            console.log(t);
        }
    });
}), e(t, "getClassType", function() {
    var t = this, e = a.getNetAddresss("plugin.debt-shop.frontend.goods.recommendCategory");
    a._getNetWork({
        url: e,
        success: function(e) {
            var a = e.data;
            if (1 == a.result) {
                if (console.log(a.data.length), a.data.length <= 9) a.data.push({
                    id: 0,
                    thumb_url: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/debt/allClass.png",
                    name: "全部分类"
                }); else {
                    if (a.data.length >= 10) {
                        return a.data.push({
                            id: 0,
                            thumb_url: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/debt/allClass.png",
                            name: "全部分类"
                        }), void t.setData({
                            ClassTypeInfo: a.data.slice(0, 10),
                            navArr: a.data.slice(10)
                        });
                    }
                    if (19 == a.data.length) {
                        return a.data.push({
                            id: 0,
                            thumb_url: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/debt/allClass.png",
                            name: "全部分类"
                        }), t.setData({
                            ClassTypeInfo: a.data.slice(0, 10),
                            navArr: a.data.slice(10)
                        }), void console.log(a.data);
                    }
                }
                t.setData({
                    ClassTypeInfo: a.data,
                    navArr: []
                }), console.log(t.data.ClassTypeInfo);
            } else wx.showToast({
                icon: "none",
                title: a.msg,
                duration: 1500
            });
        },
        fail: function(t) {
            console.log(t);
        }
    });
}), t));